This was actually ^Neptune's request, so here it is.
YouTube! When you're chatting with your friends on IRC, you'll usually encounter some YouTube links to videos. But ever wonder what the video is? Instead of opening a new tab in your browser to see actually "what" it is, you can have a personal YouTube URL Detector.
Just load it onto a bot, put a YouTube URL, and it'll give you information on the following:
[size=16]Newer news[/size]
[size=14]Updates![/size]: I've removed the TinyURL edition for specific reasons, mentioned below. I might post a snippet on it later, but it will not be in this snippet. (If you liked the older version and enjoyed the benefit of downloading the videos, check out the older version here.
I've also enhanced the speed of the script, removed the use of key identifiers such as $between and $htmlfree, and reduced script space. Triple the pleasure?
[size=16]Older news[/size]
If you do not like the new update: > Some of you might say that the TinyURL links do not work, or it leads to a blank page and halts.
"It is most likely because it is a .flv file and/or unknown to the web browser."
[size=14]Edit[/size]: That is false. I've later realized that the URL is actually user-based, essentially only one person can access it, or the bot owner; the owner sockopens to the YouTube site, and therefore, given a specific code that expires when accessed.
Despite the update, I doubt many will be intrigued to even download a certain YouTube video (if you can stream it online, why download it?), so I'm not worried much.
Otherwise, the TinyURL's should work if the selected browser detects it.
If your browser happens to detect the video, the video name should be called video.flv.
If you find any bugs, let me know!
If you can't see the picture:
<@noob> http://www.youtube.com/watch?v=eghL7ORV1lg
<@null> [YouTube]: Title: Seinfeld - Million to One Shot Doc | By: NIGathan (uploaded on August 12, 2008) | Duration: 2mins 8secs | Views: 7,573 | Rating: 4.5 (11 ratings)
If you can't see the picture:
<@noob> http://www.youtube.com/watch?v=eghL7ORV1lg
<@null> [YouTube]: Title: Seinfeld - Million to One Shot Doc | By: NIGathan (uploaded on August 12, 2008) | Duration: 2mins 8secs | Views: 7,573 | Rating: 4.5 (11 ratings) | Download: http://tinyurl.com/dem5lq (http://preview.tinyurl.com/dem5lq)
Updates:
Update #1 - Sat Mar 27, 11:32 AM: Fixed the bug with the "duration" with ^Neptune's $between.
Update #2 - Sat Mar 28, 11:47 AM: Added error checks to see if the video exists or not.
Update #3 - Sun Mar 29, 11:36 AM: Fixed minor bug (if ratings on the video are disabled).
Update #4 - Tue Mar 31, 6:25 PM: Fixed bug where it gets text after the video url. Thanks to Jonesy44 for the regex help.
Update #5 - Mon Apr 13, 9:33 PM: Added TinyURL link to direct link to the YouTube Video, for downloading. (.flv file called video.flv)
Enjoy! :D
;SOF
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
; YouTube Video "Detector" ;
; Made by Kirby (Quakenet) ;
;*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
;// YouTube Detector Identifiers //
alias -l addmark { return $+($sock($1).mark,$chr($3),$2) }
alias -l smsg { msg $iif(c isincs $chan($1).mode,$1 $strip($2-),$1-) }
;// YouTube Detector Text Event //
on *:text:*youtube.com/watch?v=*:#: {
if (!$sock(youtube)) {
noop $regex($strip($1-),http:\/\/.*youtube.*\/watch\?v=(.{11})&?.*)
sockopen youtube www.youtube.com 80 | sockmark youtube $+(#,>,$regml(1))
}
}
;// YouTube Detector Socket (Video Information) //
on *:sockopen:youtube: {
sockwrite -n $sockname GET $+(/watch?v=,$gettok($sock(youtube).mark,2,62)) HTTP/1.0
sockwrite -n $sockname Host: www.youtube.com
sockwrite -n $sockname $crlf
}
on *:sockread:youtube: {
var %x | sockread %x
if ($regex(%x,<meta\sname="title"\scontent="(.+)">)) sockmark youtube $addmark(youtube,Title: $+(,$regml(1),),62)
elseif ($regex(%x,"length_seconds":\s"(\w+)")) sockmark youtube $addmark(youtube,Duration: $+(,$duration($regml(1)),),62)
elseif ($regex(%x,title="(.+)">.+<span\sclass="smallText">(.+)\sratings<\/span>)) sockmark youtube $addmark(youtube,$+($regml(1),>,$regml(2)),62)
elseif ($regex(%x,view-count">(.+)<\/span>\s)) { sockmark youtube $addmark(youtube,$regml(1),62) }
elseif ($regex(%x,date">(.+)<\/span>)) sockmark youtube $addmark(youtube,$+($chr(40),uploaded on $regml(1),$chr(41)),62)
elseif ($regex(%x,<a\sclass="url"\shref="\/user\/(\w+)")) sockmark youtube $addmark(youtube,By: $+(,$regml(1),),62)
}
on *:sockclose:youtube: {
tokenize 62 $sock(youtube).mark | var %x $numtok($sock(youtube).mark,62)
smsg $1 [1,0You0,4Tube]: $iif(%x >= 7,$3 $chr(124) $5 $6 $chr(124) $4 $chr(124) Views: $+(,$iif(%x == 7,$7,$9),) $chr(124) Rating: $iif(%x == 9,$+(,$7,) $+($chr(40),$8 $iif($8 == 1,rating,ratings),$chr(41),),$+(,Ratings were disabled,)),Either the video doesn't exist or it contained a malformed video ID.)
}
;EOF
the hell is all this :(
[5:55:44pm] <@chachin> http://www.youtube.com/watch?v=lVefgfmFg9o
[5:55:45pm] <@chick3n> [YouTube]: Title: Hand back into the Large Hadron Collider - Sixty Symbols | <span class="stat" by <span class="yt-user-name " dir="ltr" | (uploaded on Man Returns Phone To Best Buy, Gets 'Gay' Facebook Update</span | Views: <span class="stat" | Rating: Ratings were disabled
hey guys. i asked Ford_Lawnmower to look into updating this a couple days ago. and he did us the favor of making a updated script.
heres the url: http://www.hawkee.com/snippet/8814/
Why it doesn't load on me?
[17:53] http://www.youtube.com/watch?v=RM-ndYlWTcY&feature=player_embedded#at=12
[17:53] [1,0You0,4Tube]: Either the video doesn't exist or it contained a malformed video ID.
um... yah
Same as dreamlord
@Killlerx: http://www.youtube.com/watch?v=5GMMB73oiLs
@Killlerbotx: [YouTube]: Either the video doesn't exist or it contained a malformed video ID.
Nope doesnt work...http://www.youtube.com/watch?v=EpbmMhNe6aA
[YouTube]: Either the video doesn't exist or it contained a malformed video ID.Bielie , here http://www.hawkee.com/phpBB2/viewtopic.php?t=22062&highlight=youtube , Jethro_ come up with a solution :) ( youtube likes to change everything from time to time :) )
works fine for me...
«Fri-12:38pm» http://www.youtube.com/watch?v=eghL7ORV1lg
«Fri-12:38pm» [YouTube] "Seinfeld - Million to One Shot Doc" --- 14,237 views ( 20 likes, 2 dislikes ) uploaded by NIGathan
Might have been that youtube was taking too long to respond, or you had some other connection trouble between the bot and the site. Unless you have altered the code and it no longer works.
errm this script doent work i used the exact same url from the example and it said this
<~airsoftglock> http://www.youtube.com/watch?v=eghL7ORV1lg
sorry PsyTrance , i can't help with that one , i tried , but seems the duration of the video is not in the html source code ( from where the script reads to search everything , go to any video and in your browser check the source code , search the time and you will see is not there ; all the durations i can see are from the related videos but no the playing one :( ) , i tried with several videos , seems like the duration is embedded in some way in the flash player and not in the html itself , maybe someone else with more experience in scripting can help us with that :)
PS : i add something i found :) i replaced
title="(.+)"> )) set %youtuberating $regml(1)
with
title="(.+)">)) set %youtuberating $regml(1)
only deleted the space after title="(.+)"> , in some videos was not working right
exactly , for some reason ( kind of noob to this still so idk why , actually this one was my firs or second script using sockets :) ) , the $chan doesnt work within the sockclose event , so you need to use the actual name of the channel ( #blabla , if you have only 1 ) or a variable like lucius said :)
UPDATED 2 DECEMBER 2010
here http://www.hawkee.com/phpBB2/viewtopic.php?t=22062&highlight=youtube , Jethro_ come up with a solution :)
this one works ( USED TO , i keep it here just in case) ( just my small adaptation of the original here ) :)
; ********** YOUTUBE ****************************
on *:text:*youtube.com/watch?v=*:#: {
if (!$sock(youtube)) {
noop $regex($strip($1-),http:\/\/.*youtube.*\/watch\?v=(.{11})&?.*)
sockopen youtube www.youtube.com 80 | sockmark youtube $+(#,>,$regml(1))
}
}
on *:sockopen:youtube: {
sockwrite -n $sockname GET $+(/watch?v=,$gettok($sock(youtube).mark,2,62)) HTTP/1.0
sockwrite -n $sockname Host: www.youtube.com
sockwrite -n $sockname $crlf
}
on *:sockread:youtube: {
var %x | sockread %x
if ($regex(%x,<meta name="title" content="(.+)">)) set %youtubetitle $regml(1)
elseif ($regex(%x,<strong class="watch-view-count">(.+)</strong><br>)) set %youtubeviews $regml(1)
elseif ($regex(%x,<span class="watch-video-date">(.+)</span>)) set %youtubedate $regml(1)
elseif ($regex(%x,<div class="action-bar-ratings-stats yt-uix-tooltip" title="(.+)"> )) set %youtuberating $regml(1)
elseif ($regex(%x,<a id="watch-username" class="inline-block" href="/user/(.+)">)) set %youtubeuser $regml(1)
}
on *:sockclose:youtube: {
msg #CHANNEL $chr(91) $+ YouTube $+ $chr(93) " $+ %youtubetitle $+ " --- %youtubeviews views $&
( %youtuberating ) uploaded %youtubedate by %youtubeuser ---
unset %youtube*
}
; ************************************************
[14:52:16] http://www.youtube.com/watch?v=wnNhxqD1FTA
[14:52:18] [YouTube] "That's the Thing about Football 2008" --- 14,602 views ( 33 likes, 1 dislikes ) uploaded by TheSwert ---
just change the name of your channel in
on *:sockclose:youtube
You've seen them scripts, but that doesn't mean you can get them. Unless, of course, the people who own 'em are generous enough to give you a copy. From my own experience, people who own something good will rather keep it to themselves, though...'cause they don't want other folks to have what they got distributed all over the place. This is sort of like a secret family recipe saying: if I told you, I'd have to kill you. Don't get me wrong on that matter...there's still a chance, but it's not that great.
Unfortunately a lot of people like that exist. The thing they don't realise is what goes around comes around.
You've seen them scripts, but that doesn't mean you can get them. Unless, of course, the people who own 'em are generous enough to give you a copy. From my own experience, people who own something good will rather keep it to themselves, though...'cause they don't want other folks to have what they got distributed all over the place. This is sort of like a secret family recipe saying: if I told you, I'd have to kill you. Don't get me wrong on that matter...there's still a chance, but it's not that great.
No shit, it's almost six years old, YouTube's layout has changed so much it won't work at all.